//
//  BRBannerView.m
//  BrezzeSaaS
//
//  Created by IOS on 2023/5/27.
//  Copyright © 2023 Brezze GWG. All rights reserved.
//

#import "BRBannerView.h"

@interface BRBannerView ()
{
    UIView *_contentView;
    UIImageView *_rightImg;
    QMUILabel *_titleL;
    QMUILabel *_contentLB;
}
@end

@implementation BRBannerView

- (instancetype)init
{
    self = [super init];
    if (self) {
        [self setUI];
    }
    return self;
}

- (void)btnClick {
    if(self.btnClickBlock) self.btnClickBlock();
}


#pragma mark - UI --
- (void)setUI {
    
    _contentView = [[UIView alloc] init];
    _contentView.backgroundColor = UIColor.qd_backgroundColor3;
    _contentView.layer.cornerRadius = 10.;
    _contentView.layer.masksToBounds = YES;
    _contentView.userInteractionEnabled = YES;
    [self addSubview:_contentView];
    [_contentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(0);
        make.left.offset(0);
        make.right.offset(0);
        make.bottom.offset(0);
        make.height.mas_greaterThanOrEqualTo(98);
    }];
    
    _rightImg  = [[UIImageView alloc] init];
    _rightImg.image = [UIImage imageNamed:@"home_banner"];
    [_contentView addSubview:_rightImg];
    [_rightImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(96);
        make.height.mas_equalTo(98);
        make.centerY.offset(0);
        make.right.offset(-16);
    }];
    
    
    _titleL = [[QMUILabel alloc] init];
    _titleL.text = Localized(@"home_bannerText");
    _titleL.numberOfLines = 0;
    _titleL.font = [UIFont br_fontB:17];
    _titleL.textAlignment = NSTextAlignmentLeft;
    _titleL.textColor = UIColor.qd_titleTextColor;
    [_contentView addSubview:_titleL];
    [_titleL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(16);
        make.right.offset(-112);
        make.top.offset(16);
    }];
    
    
    _contentLB = [[QMUILabel alloc] init];
    _contentLB.numberOfLines = 0;
    _contentLB.text = Localized(@"home_bannerSubText");
    _contentLB.textAlignment = NSTextAlignmentLeft;
    _contentLB.font = [UIFont br_fontM:12];
    _contentLB.textColor = UIColor.qd_titleTextColor;
    [_contentView addSubview:_contentLB];
    [_contentLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(16);
        make.right.offset(-112);
        make.top.equalTo(_titleL.mas_bottom).offset(4);
        make.bottom.mas_lessThanOrEqualTo(_contentView.mas_bottom).offset(-16);
    }];
    
    
//    self.layer.shadowColor = [UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:0.10].CGColor;
//    self.layer.shadowOffset = CGSizeMake(0,5);
//    self.layer.shadowRadius = 8;
//    self.layer.shadowOpacity = 1;
    
    UIControl *btn = [[UIControl alloc] init];
    [_contentView addSubview:btn];
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.offset(0);
    }];
    [btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
}

@end
